<template>
  <div class="shopinfo">
    <div class="top">
      <p @click="$router.go(-1)">&lt;</p>
      <div class="title">
        <div class="touxiang">
          <img src="" alt="">
        </div>
        <div class="shopname">
          店名
        </div>
      </div>
      <div class="opt">
        <input type="text" placeholder="搜索" />
        <span :class="{active: optsIndex == index}" v-for="(item, index) in opts" :key="index" @click="optsIndex = index">{{ item }}</span>
      </div>
      <div class="message">

      </div>
    </div>
    <div class="middle">
      <div class="taglist">
        <div
          :class="{tag:true,active:tagIndex==index}"
          v-for="(item, index) in taglist"
          :key="index"
          @click="handleClick(item.name,index)"
        >
          {{ item.name }}
        </div>
      </div>
      <div class="shopinfolist">
        <h5>{{ tagName }}</h5>
        <div
          class="item"
          v-for="(item, index) in taglist[tagIndex].goodlist"
          :key="index"
        >
          <div class="left">
            <img :src="item.picture" alt="" />
          </div>
          <div class="right">
            <div class="name">
              {{ item.name }}
            </div>
            <div class="sales">
              {{ item.month_saled_content }}
            </div>
            <div class="show">
              <div class="price">￥{{ item.min_price }}</div>
              <div class="add">+</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="bottom">
      <div class="car">购物车</div>
      <div class="jiezhang">去结算</div>
    </div>
  </div>
</template>

<script>
import { shop_info } from "../api/index";

export default {
  data() {
    return {
      opts: ["点餐", "评价", "商家"],
      optsIndex: 0,
      taglist: [],
      tagIndex: 0,
      tagName:''
    };
  },
  methods: {
    handleClick(name,index) {
      this.tagName=name
      this.tagIndex = index;
    },
  },
  mounted() {
    shop_info(this.$route.params).then((res) => {
      // console.log(res.data.shopinfo.taglist);
      this.taglist = res.data.shopinfo.taglist;
      this.tagName=this.taglist[0].name
    });
  },
};
</script>

<style scoped>
.shopinfo {
  width: 360px;
  height: 600px;
  background-color: gainsboro;
  margin: 30px auto;
  position: relative;
}
.top{
  padding: 10px;
}
.top p{
  height: 30px;
  line-height: 30px;
  font-size: 28px;
  color: white;
  cursor: pointer;
  /* background-color: red; */
}
.title{
  height: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  /* background-color: orange; */
}
.touxiang{
  width: 30px;
  height: 30px;
  margin-right: 10px;
  /* border-radius: 50%; */
  background-color: #fff;
}
.touxiang img{
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.shopname{
  flex: 1;
  color: white;
}
.opt{
  height: 30px;
  font-size: 12px;
  color: white;
  /* background-color: yellow; */
}
input{
  width: 60px;
  height: 26px;
  color: white;
  font-size: 12px;
  text-align: center;
  border-radius: 20px;
  margin-right: 10px;
  background-color: rgba(255, 255, 255, 0.573);
}
.opt span{
  display: inline-block;
  margin-right: 20px;
  cursor: pointer;
}
.opt .active{
  color: rgb(5, 148, 237);
  border-bottom: 2px solid rgb(5, 148, 237);
}
.message{
  padding: 0 10px;
  height: 80px;
  background-color: #fff;
  border-radius: 5px;
}
.middle{
  height: 320px;
  display: flex;
  justify-content: space-between;
  background-color: #fff;
  font-size: 12px;
  color: gray;
  padding-top: 10px;
}
.taglist{
  width: 120px;
  overflow-y: auto;
  /* background-color: green; */
}
::-webkit-scrollbar{
  display: none;
}
.tag{
  height: 24px;
  line-height: 24px;
  padding-left: 10px;
  cursor: pointer;
  margin: 10px 0;
}
.tag.active{
  color: black;
  font-weight: 700;
  border-left: 3px solid red;
}
.bottom{
  width: 100%;
  height: 50px;
  background-color: rgba(0, 0, 0, 0.821);
  color: #fff;
  display: flex;
  justify-content: space-around;
  align-items: center;
  position: absolute;
  bottom: 0;
}
.shopinfolist{
  width: 240px;
  padding: 0 5px;
  overflow-y: auto;
  /* background-color: aquamarine; */
}
h5{
  height: 30px;
  line-height: 30px;
  color: black;
}
.item{
  height: 80px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}
.left{
  width: 80px;
  height: 80px;
}
.left img{
  width: 100%;
  height: 100%;
}
.right{
  width: 140px;
}
.name{
  height: 40px;
  font-size: 12px;
  font-weight: 700;
  color: black;
}
.show{
  margin-top: 10px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  padding-right: 5px;
}
.price{
  color: red;
  font-weight: 700;
}
.add{
  width: 16px;
  height: 16px;
  border-radius: 50%;
  text-align: center;
  line-height: 16px;
  color: white;
  background-color: rgb(5, 148, 237);
}
</style>